package com.village.friend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.village.friend.entity.UserWechatLook;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

public interface  UserWechatLookMapper extends BaseMapper<UserWechatLook> {
    @Insert("insert into  user_wechat_look(user_id,user_id_looked,is_looked)  values (#{userId},#{userIdLooked},1) on  duplicate key update  is_looked=1, update_time=now()")
    Integer insertOrUpdate(Integer userId, Integer userIdLooked);

    @Select("select count(1) from  user_wechat_look where user_id=#{userId} and update_time> concat(date(NOW()) ,' 00:00:00')  ")
    Integer getTodayUserLookCount(Integer userId);

    @Select("select user_id userId,user_id_looked userIdLooked,create_time createTime,update_time updateTime from  user_wechat_look where user_id=#{userId} and user_id_looked = #{userIdLooked}  and update_time> concat(date(NOW()) ,' 00:00:00') limit 1")
    UserWechatLook getUserLook(Integer userId, Integer userIdLooked);

}
